package net.zoneland.knowledge;

import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;

import com.google.common.collect.Lists;

import net.zoneland.knowledge.constant.SystemConstant;
import net.zoneland.knowledge.model.EsQuestion;

/**
 * .
 *
 * @author: bcc
 *     2022/4/2
 */
public class EsQuestionUtils {

    public static void fillInfo(EsQuestion record) {
        record.setId(record.getPk());
        record.setLevel1Title2(record.getLevel1Title());
        record.setLevel2Title2(record.getLevel2Title());
        record.setLevel3Title2(record.getLevel3Title());
        record.setAnswer2(record.getAnswer());
        record.setQuestion2(record.getQuestion());
        if(null == record.getOrder() && null  != record.getNum()) {
            record.setOrder(record.getNum().longValue());
        }
        boolean roleControl = false;
        if (CollectionUtils.isNotEmpty(record.getUserIds())
            || CollectionUtils.isNotEmpty(record.getDeptIds())
            || CollectionUtils.isNotEmpty(record.getRoleFlags())) {
            roleControl = true;
        }
        if (roleControl) {
            if (org.springframework.util.CollectionUtils.isEmpty(record.getUserIds()) ) {
                record.setUserIds(Lists.newArrayList("#"));
            }
            if (org.springframework.util.CollectionUtils.isEmpty(record.getDeptIds()) ) {
                record.setDeptIds(Lists.newArrayList("#"));
            }
            if (org.springframework.util.CollectionUtils.isEmpty(record.getRoleFlags()) ) {
                record.setRoleFlags(Lists.newArrayList("#"));
            }
        }
    }

}
